# -*- encoding=utf8 -*-
        
__author__ = "Bryan.Chen"
__desc__=""
        
from airtest.core.api import *
        
auto_setup(__file__)
        
from poco.drivers.std import StdPoco
poco = StdPoco()
        
using("../FlowTest.air")
import FlowTest
        
class SubGame_WaitToStart(FlowTest.BaseTestCase):
    def __init__(self):
        print("%s __init__" % (__file__))
        
    def runTest(self, args):
        print("%s runTest" % (__file__))

        btnReady = poco("ready_btn")
        if btnReady.exists():
            self.clickButton(btnReady)
        
        isTimeOut = False
        t1 = time.time()
        while True:
            if poco("LobbyScene").exists():
                break

            if time.time() - t1 > 2 * 60:
                isTimeOut = True
                break

        # 超时了，就解散房间
        if isTimeOut:
            btnCloseRoom = poco("close_room_btn")
            self.clickButton(btnCloseRoom)

            tipsLobbyLayer = poco("TipsLobbyLayer")
            btnOK = tipsLobbyLayer.offspring("ok_btn_2")
            self.clickButton(btnOK)

            vipOverLayer = poco("VipOverLayer")
            btnClose = vipOverLayer.offspring("Button_close")
            self.clickButton(btnClose) # 回到子游戏大厅 

        return True
        
_instance = SubGame_WaitToStart()
runTest = _instance.runTest
